<?php
namespace app\activity\model;
use think\Model;
class Letter extends Model{
    protected $table = 'bk_letter';
    protected $autoWriteTimestamp = 'datetime';

    const STATUS = [
        0=>'进行中',
        1=>'已确认',
    ];

    public function getValue($where,$column='id'){
        return self::where($where)->value($column);
    }

    public function createLetter($data){
        return self::create($data);
    }

    public function updateLetter($data){
        return self::where('id', $data['id'])->update($data);
    }

    public function getList($where=[],$order=['id'=>'desc']){
        return self::where($where)->order($order)->select();
    }

    public function getPageList($page=0,$limit=2,$where=[],$order=['id'=>'desc']){
        return self::where($where)->order($order)->limit($page,$limit)->select();
    }

    public function getCount($where=[]){
        return self::where($where)->count();
    }

    public function Customer(){
        return $this->belongsTo('Customer','customer_id','id');
    }

    public function Manager(){
        return $this->belongsTo('Manager','manager_id');
    }
}